<?php

namespace Wap\Controller;
use Index\Controller\CommonController;

class CateController extends CommonController {

    private $Cate;

    public function __construct(){
        parent::__construct();
        $this->Cate = new \Common\Model\BookCateModel();

    }

    //章节列表
    public function index(){
        $cate_id = I('get.cate_id');
        if($cate_id > 0){
            $where = "`cate_id` = '{$cate_id}'";
        }
        $Book = new \Common\Model\BookModel();
        $this->limit = 20;
        $this->offset = ($this->page-1) * $this->limit;
        $books = $Book->getList($where, $order = '', $this->offset, $this->limit,$fields ='');
        $this->assign('totalPage',ceil($books['total']/$this->limit));
        if($cate_id > 0){
            $where = "`cate_id` = '{$cate_id}'";
        }
        $cates = $this->Cate->where('is_view = 2')->select();

        $this->assign('books',$books);
        $this->assign('cates',$cates);
        $this->assign('title','分类');
        $this->assign('cate_id',empty($cate_id)?0:$cate_id);
        $this->display('Index/cate');
    }



}